<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>输入法选择</title>
    <style>
        * {
            margin: 0;
            padding: 0;
        }

        ul>li {
            list-style: none;
        }

        div {
            width: 100px;
            margin: 0 auto;
            text-align: center;
        }

        ul {
            display: none;
            margin-top: 4px;
        }
        li{
            width: 140px;
            border: 1px solid #ccc;
            margin-left: -21px;
        }
        li:hover{
            background-color: #D44947;
        }
    </style>
</head>

<body>
    <div>
        <button id="btn" onclick="btn()">输入法</button>
        <ul id="uu">
            <li id="li">百度输入法</li>
            <li>搜狗拼音输入法</li>
            <li>QQ拼音输入法</li>
            <li>微软拼音</li>
            <li onclick="btn()">关闭</li>
        </ul>
    </div>

    <script>
        var ui = document.getElementById('uu')
 
        function btn() {           
            if(ui.style.display == ''){
                ui.style.display = 'block'
                console.log(ui.style.display);
            }else if(ui.style.display == 'block'){
                ui.style.display = 'none'
                console.log(ui.style.display);
            }else{
                ui.style.display = 'block'
            }
        }
    </script>

</body>

</html>